﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;

/*
 *unity使用多线程
 * 
 */

public class Game_Thread : MonoBehaviour
{
    // Start is called before the first frame update
    private Thread r;  //创建一个线程

    
    void Start()
    {
        r = new Thread(this.thread_with_params);
        r.Start("other");   //线程通过委托执行一个方法
        
        //主线程普通调用
        this.thread_with_params("main");
    }

    void thread_with_params(object o1)
    {
        string s =(string)o1; 
        Debug.Log(s+"thread name:"+Thread.CurrentThread.ManagedThreadId);  //获取当前Thread id
    }

// Update is called once per frame
    void Update()
    {
        
    }
}
